/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.supinfo.youfood.web.servlet.serveur;

import com.supinfo.youfood.entity.Commande;
import com.supinfo.youfood.entity.Employe;
import com.supinfo.youfood.service.CommandeService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author TaKeO
 */
@WebServlet(name = "AccueilServeurServlet", urlPatterns = {"/serveur/accueil"})
public class AccueilServeurServlet extends HttpServlet 
{
    
    @EJB
    private CommandeService commandeService;
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        Employe currentEmp = (Employe)request.getSession(true).getAttribute("currentEmp");
        int nbCommandesEnCours = currentEmp.getCommandesEnCours().size();
        List<Commande> listCommandes = new ArrayList<Commande>();
        listCommandes = commandeService.getAllCommandesByRestaurant(currentEmp.getResto());
        
        request.setAttribute("nbCommandesEnCours", nbCommandesEnCours);
        request.setAttribute("commandes", listCommandes);
        request.getRequestDispatcher("/jsp/serveur/accueil.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        
    }
}
